<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>

<!DOCTYPE html>
<html>
	<head>
		<title>排课复制</title>
		<meta name="decorator" content="default"/>
		<script type="text/javascript">     
			$(function(){ 
				var defHeight = 300,wh=$(window).height();
				var lh=$('.location').height(),fh=$('#floatHead').height(),sh=$('.det-list').height(),ph=$('.pagelist').height();
				defHeight = (wh-lh-fh-sh-ph-130);
				$('.flexgrid').flexigrid({striped:true,height:defHeight});
				
				$('#year').blur(function(){
					var year = 
					$.ajax({
						url:'${ctx}/qd/course/ajax?method=week',
						data:{year:$('#year').val()},
						success:function(res){
							var json = eval('('+res+')');
							
							var select = $('#nweek');
							select.empty();
							
							for(week in json){
								var infos = json[week].split(':');
								var opt = $('<option value="'+infos[1]+'">'+infos[0]+'</option>');
								select.append(opt);
							}
							$('.rule-single-select').ruleSingleSelect();
						},
						error:function(res){
							jsprint('获取星期错误:'+res.responseText);
						}
					});
				});
				
				$('#fyear').blur(function(){
					var year = 
					$.ajax({
						url:'${ctx}/qd/course/ajax?method=week',
						data:{year:$('#fyear').val()},
						success:function(res){
							var json = eval('('+res+')');
							
							var select = $('#fweek');
							select.empty();
							
							for(week in json){
								var infos = json[week].split(':');
								var opt = $('<option value="'+infos[1]+'">'+infos[0]+'</option>');
								select.append(opt);
							}
							$('.rule-single-select').ruleSingleSelect();
						},
						error:function(res){
							jsprint('获取星期错误:'+res.responseText);
						}
					});
				});
				
				$('#tyear').blur(function(){
					var year = 
					$.ajax({
						url:'${ctx}/qd/course/ajax?method=week',
						data:{year:$('#tyear').val()},
						success:function(res){
							var json = eval('('+res+')');
							
							var select = $('#tweek');
							select.empty();
							
							for(week in json){
								var infos = json[week].split(':');
								var opt = $('<option value="'+infos[1]+'">'+infos[0]+'</option>');
								select.append(opt);
							}
							$('.rule-single-select').ruleSingleSelect();
						},
						error:function(res){
							jsprint('获取星期错误:'+res.responseText);
						}
					});
				});
			});
			
			function page(n,s){
				$("#pageNo").val(n);
				$("#pageSize").val(s);
				$("#searchForm").submit();
	        	return false;
	        }
	        
	        function deleteAll(){
				var ids =[];//定义一个数组    
	            $('input[name="checkall"]:checked').each(function(){    
	                ids.push($.trim($(this).val()));
	            });
	            document.location.href='${ctx}/qd/attach/delete?ids='+ids;
			}
	        
	      	//全选取消按钮函数
	        function checkAll(chkobj) {
	            if ($(chkobj).prop("checked")) {
	                $(".checkall input:enabled").prop("checked", true);
	            } else {
	                $(".checkall input:enabled").prop("checked", false);
	            }
	        }
		</script>
		<style type="text/css">
			.det-list .group .control{width:auto !important;}
		</style>
	</head>
	
	<body class="mainbody">
		<sys:message content="${message}"/>
		${js}
		<!--导航栏--> 
		<div class="location">
			<a href="${ctx}/qd/course/list" class="back"><i></i><span>返回列表页</span></a>
			<a href="${ctx}/center" class="home"><i></i><span>首页</span></a> 
			<i class="arrow"></i> 
			<a href="#"><span>排课</span></a>
			<shiro:hasPermission name="qd:course:edit"><i class="arrow"></i><span>排课复制</span></shiro:hasPermission>
		</div>
		<div class="line10"></div>
		<!--/导航栏-->
		
		<form method="post">
			<!--搜索栏-->
			<div class="det-list clearfix">
			    <div class="group btm">
					<div class="control">
			            <div class="title">复制从</div>
			            <input id="year" name="year" class="input normal" value="${year}" onfocus="WdatePicker({dateFmt:'yyyy'})" style="width:50px;text-align: center;"/>
			            <div class="rule-single-select single-select">
							<select id="nweek" name="nweek">
								<option value="">请选择</option>
								<c:forEach items="${weeks}" var="week">
								<option value="${week.value()}" ${week.value().equals(nweek)?'selected':''}>${week.text()}</option>
								</c:forEach>
							</select>			
						</div>
						<input type="submit" name="btnSearchSubmit"  value="搜索" id="btnDetailedSearch" class="btn">
			        </div>
			    </div>
			    <div class="group btm">
					<div class="control">
			            <div class="title">复制到</div>
			            <input id="fyear" name="fyear" class="input normal" value="${fyear}" onfocus="WdatePicker({dateFmt:'yyyy'})" style="width:50px;text-align: center;"/>
			            <div class="rule-single-select single-select">
							<select id="fweek" name="fweek">
								<option value="">请选择</option>
								<c:forEach items="${fweeks}" var="week">
								<option value="${week.value()}" ${week.value().equals(fweek)?'selected':''}>${week.text()}</option>
								</c:forEach>
							</select>
						</div>
						<span>-</span>
						<input id="tyear" name="tyear" class="input normal"  value="${tyear}" onfocus="WdatePicker({dateFmt:'yyyy'})" style="width:50px;text-align: center; margin-left:5px;"/>
			            <div class="rule-single-select single-select">
							<select id="tweek" name="tweek">
								<option value="">请选择</option>
								<c:forEach items="${tweeks}" var="week">
								<option value="${week.value()}" ${week.value().equals(tweek)?'selected':''}>${week.text()}</option>
								</c:forEach>
							</select>
						</div>
						<input type="submit" name="btnCopySubmit" value="开始复制" id="btnCopySubmit" class="btn yellow">
			        </div>
			    </div>      
			    <div style="clear:both;"></div>
			</div>
			<!--/搜索栏-->
			
			<!--列表-->
			<div class="table-container">
				<table class="flexgrid">
					<thead>
						<tr>
							<th width="25" style="text-align: center;"><input type="checkbox" name="btncheckall" onclick="checkAll(this); "/></th>
							<th width="120" style="text-align: center;">日期</th>
							<th width="80" style="text-align: center;">上课时间</th>
							<th width="80" style="text-align: center;">系列</th>
							<th width="80" style="text-align: center;">阶段</th>
							<th width="80" style="text-align: center;">主题</th>
							<th width="80" style="text-align: center;">上课教室</th>
							<th width="80" style="text-align: center;">教师1</th>
							<th width="80" style="text-align: center;">教师2</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${courseList}" var="course">
						<tr>
							<td style="text-align:center;">
								<span class="checkall" style="vertical-align: middle;">
									<input type="checkbox" name="checkall" value="${course.id}" />
								</span> 
							</td>
							<td style="text-align: center;"><fmt:formatDate value="${course.ondate}" pattern="yyyy-MM-dd"/>[${course.getWeekDay()}]</td>
							<td style="text-align: center;">${course.section}</td>
							<td style="text-align: center;">${course.serial}</td>
							<td style="text-align: center;">${course.clevel}</td>
							<td style="text-align: center;">${course.theme}</td>
							<td style="text-align: center;">${course.classroom}</td>
							<td style="text-align: center;">${course.teacher}</td>
							<td style="text-align: center;">${course.teacher2}</td>
						</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
			<!--/列表-->
		</form>
	</body>
</html>

